home *** CD-ROM | disk | FTP | other *** search
/ PC Users 1999 May / Cd Pc Users extra 20 mayo 1999.iso / Prog / Inst / FTP / GETPRO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1999-03-18  |  2.4 KB  |  90 lines

  1. /*
  2. **  GETPRO.C
  3. **
  4. **  This program downloads PRODUCTS.TXT from our FTP site at
  5. **  ftp://ftp.marshallsoft.com/marshallsoft/other/products.txt
  6. **
  7. **  Change PASSWORD (line 23) to your password before compiling.
  8. */
  9.  
  10. #include <windows.h>
  11. #include <winsock.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include <ctype.h>
  16. #include "fce.h"
  17.  
  18. #define SRVR_NAME   "ftp.marshallsoft.com"
  19. #define USER_NAME   "anonymous"
  20. #define PASSWORD    "msc@traveller.com"
  21. #define DIRECTORY   "msc/other"
  22. #define FILE_NAME   "products.txt"
  23.  
  24. char Temp[51];
  25.  
  26. /* globals */
  27.  
  28. void ShowError(int Code)
  29. {Temp[0] = '\0';
  30.  fceErrorText(0,Code,(LPSTR)Temp,50);
  31.  printf("ERROR %d: %s\n", Code, Temp);
  32. }
  33.  
  34. void ErrorExit(int Code)
  35. {ShowError(Code);
  36.  fceRelease();
  37.  exit(1);
  38. }
  39.  
  40. void main(int argc, char *argv[])
  41. {int Code;
  42.  ULONG ByteCount;
  43.  int Version;
  44.  int Build;
  45.  /* check arguments */
  46.  if(argc!=1)
  47.    {printf("Usage: GETPRO\n");
  48.     exit(1);
  49.    }
  50.  printf("GETPRO 02/05/99\n");
  51.  printf("Server : %s\n", SRVR_NAME);
  52.  printf("  User : %s\n", USER_NAME);
  53.  printf("  Pass : %s\n", PASSWORD);
  54.  printf("   Dir : %s\n", DIRECTORY);
  55.  printf("  File : %s\n", FILE_NAME);
  56.  printf("\nDownloading %s/%s/%s\n",SRVR_NAME,DIRECTORY,FILE_NAME);
  57.  /* attach FCE */
  58.  Code = fceAttach(1);
  59.  if(Code<0) ErrorExit(Code);
  60.  Version = fceGetInteger(0,FCE_GET_VERSION);
  61.  Build   = fceGetInteger(0,FCE_GET_BUILD);
  62.  printf("FCE32 Version: %1d.%1d.%1d Build %d\n",
  63.     0x0f&(Version>>8),0x0f&(Version>>4),0x0f&Version,Build);
  64.  fceGetString(0,FCE_GET_REGISTRATION,(LPSTR)Temp,50);
  65.  printf(" Registration: %s\n", Temp);
  66.  /* define LOG file */
  67.  fceSetString(0,FCE_SET_LOG_FILE,(LPSTR)"getpro.log");
  68.  /* connect to server */
  69.  printf("Connecting...");
  70.  Code = fceConnect(0,(LPSTR)SRVR_NAME,(LPSTR)USER_NAME,(LPSTR)PASSWORD);
  71.  if(Code<0) ErrorExit(Code);
  72.  printf("OK\n");
  73.  /* change to proper directory */
  74.  Code = fceSetServerDir(0, (LPSTR)DIRECTORY);
  75.  if(Code<0) ErrorExit(Code);
  76.  /* set to ASCII xfer mode */
  77.  fceSetMode(0,'A');
  78.  /* download the file */
  79.  printf("Please wait while file %s is being downloaded...\n",FILE_NAME);
  80.  Code = fceGetFile(0,(LPSTR)FILE_NAME);           
  81.  if(Code<0) ErrorExit(Code);
  82.  /* display final count */
  83.  ByteCount = fceGetInteger(0, FCE_GET_FILE_BYTES_RCVD);
  84.  printf("%d bytes received\n",ByteCount);
  85.  /* QUIT */
  86.  fceClose(0);
  87.  fceRelease();
  88. }
  89.  
  90.